package cn.gson.springboot.model.pjos;


import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.sql.Date;
import java.util.Objects;

@Entity
public class Exchange {
    private int excId;//id ok
    private String excOrder;//发货单 ok
    private String excTheme;//退货主题 ok
    private Integer excUserid;//负责人 ok
    private OrderInfo orderInfoByOrderId;//订单id ok
    private List<Exchangedetails> exchangedetailsByExcId;//从表 ok
    private String ecName;//退货编号 no
    private Date excNewtime;//创建时间 no
    private BigDecimal excAmount;//总金额/exc_customeid ok
    private Integer excHuanstate;//是否维修/exc_huanstate no
    private Integer excCustomeid;//客户id/exc_customeid 1 no
    private Integer excDeliveryid;//交付id/exc_deliveryid ok
    private Integer excState;//exc_state
    private Integer excMainState;//主状态exc_mainState

    @Id
    @Column(name = "exc_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getExcId() {
        return excId;
    }

    public void setExcId(int excId) {
        this.excId = excId;
    }

    @Basic
    @Column(name = "exc_order")
    public String getExcOrder() {
        return excOrder;
    }

    public void setExcOrder(String excOrder) {
        this.excOrder = excOrder;
    }

    @Basic
    @Column(name = "exc_theme")
    public String getExcTheme() {
        return excTheme;
    }

    public void setExcTheme(String excTheme) {
        this.excTheme = excTheme;
    }

    @Basic
    @Column(name = "exc_userid")
    public Integer getExcUserid() {
        return excUserid;
    }

    public void setExcUserid(Integer excUserid) {
        this.excUserid = excUserid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Exchange exchange = (Exchange) o;
        return excId == exchange.excId &&
                Objects.equals(excOrder, exchange.excOrder) &&
                Objects.equals(excTheme, exchange.excTheme) &&
                Objects.equals(excUserid, exchange.excUserid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(excId, excOrder, excTheme, excUserid);
    }

    @ManyToOne
    @JoinColumn(name = "order_id", referencedColumnName = "order_id")
    public OrderInfo getOrderInfoByOrderId() {
        return orderInfoByOrderId;
    }

    public void setOrderInfoByOrderId(OrderInfo orderInfoByOrderId) {
        this.orderInfoByOrderId = orderInfoByOrderId;
    }

    @OneToMany(mappedBy = "exchangeByExcId")
    public List<Exchangedetails> getExchangedetailsByExcId() {
        return exchangedetailsByExcId;
    }

    public void setExchangedetailsByExcId(List<Exchangedetails> exchangedetailsByExcId) {
        this.exchangedetailsByExcId = exchangedetailsByExcId;
    }

    @Basic
    @Column(name = "exc_name")
    public String getEcName() {
        return ecName;
    }

    public void setEcName(String ecName) {
        this.ecName = ecName;
    }

    @Basic
    @Column(name = "exc_Newtime")
    public Date getExcNewtime() {
        return excNewtime;
    }

    public void setExcNewtime(Date excNewtime) {
        this.excNewtime = excNewtime;
    }


    @Basic
    @Column(name = "exc_amount")
    public BigDecimal getExcAmount() {
        return excAmount;
    }

    public void setExcAmount(BigDecimal excAmount) {
        this.excAmount = excAmount;
    }

    @Basic
    @Column(name = "exc_huanstate")
    public Integer getExcHuanstate() {
        return excHuanstate;
    }

    public void setExcHuanstate(Integer excHuanstate) {
        this.excHuanstate = excHuanstate;
    }

    @Basic
    @Column(name = "exc_customeid")
    public Integer getExcCustomeid() {
        return excCustomeid;
    }

    public void setExcCustomeid(Integer excCustomeid) {
        this.excCustomeid = excCustomeid;
    }

    @Basic
    @Column(name = "exc_deliveryid")
    public Integer getExcDeliveryid() {
        return excDeliveryid;
    }

    public void setExcDeliveryid(Integer excDeliveryid) {
        this.excDeliveryid = excDeliveryid;
    }

    @Basic
    @Column(name = "exc_state")
    public Integer getExcState() {
        return excState;
    }

    public void setExcState(Integer excState) {
        this.excState = excState;
    }


    @Basic
    @Column(name = "exc_main_state")
    public Integer getExcMainState() {
        return excMainState;
    }

    public void setExcMainState(Integer excMainState) {
        this.excMainState = excMainState;
    }

    @Override
    public String toString() {
        return "Exchange{" +
                "excId=" + excId +
                ", excOrder='" + excOrder + '\'' +
                ", excTheme='" + excTheme + '\'' +
                ", excUserid=" + excUserid +
                ", orderInfoByOrderId=" + orderInfoByOrderId +
                ", exchangedetailsByExcId=" + exchangedetailsByExcId +
                ", ecName='" + ecName + '\'' +
                ", excNewtime=" + excNewtime +
                ", excAmount=" + excAmount +
                ", excHuanstate=" + excHuanstate +
                ", excCustomeid=" + excCustomeid +
                ", excDeliveryid=" + excDeliveryid +
                '}';
    }
}
